package com.lagou.code.mapper;

import com.lagou.code.entity.Code;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CodeMapper {

    @Select("SELECT * FROM lagou_auth_code WHERE email = #{email} AND code = #{code}")
    Code findByEmail(@Param("email") String email, @Param("code") String code);

    @Insert("INSERT INTO lagou_auth_code(email, code, createtime, expiretime) VALUES(#{email}, #{code}, now(), DATE_ADD(now(), INTERVAL 10 MINUTE))")
    void add(@Param("email") String email, @Param("code") String code);


}
